package com.chris.blog.config;

import com.chris.blog.entity.po.InvitePO;
import com.chris.blog.service.InviteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.Random;

@Component
public class CrontabTask {
    
    @Autowired
    private InviteService inviteService;

    @Async
    @Scheduled(cron = "0 0 0 * * ?")
    public void insert() {
        InvitePO invitePO = new InvitePO();
        invitePO.setCode(new Random().nextInt(10000) + "");
        invitePO.setGmtCreate(new Date());
        inviteService.insertSelective(invitePO);
        System.out.println("插入邀请码!!!!!!!");
    }
}
